package com.example.ljy.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

/*
创建数据库及数据库中表格
 */
public class DBHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "user.db";
    public static final String TABLE_NAME = "user_info";
    private static final int DB_VERSION = 1;
    private Context context;

    public DBHelper(@Nullable Context context,String dbname) {
        super(context, dbname, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists " + TABLE_NAME +
                "(_id integer primary key autoincrement, time vchar, temperature vchar)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        if (oldVersion == 1 && newVersion == 2) {
            //写sql语句去省级数据库
        }
    }
}
